package android.slc.extras.component.dict.vmbox

import android.slc.appbase.vmbox.AffiliatedVmBox
import android.slc.extras.component.dict.entity.ITreeDict
import android.slc.extras.component.dict.entity.TreeDictWrap

/**
 *
 * @Description:
 * @Author: sunlunchang
 * @CreateDate: 2021/12/03 上午 11:02
 *
 */
class TreeDictVmBox : AffiliatedVmBox() {
    private val sysDictListCache: MutableMap<String, TreeDictWrap> = mutableMapOf()
    private val sysDictBizListCache: MutableMap<String, TreeDictWrap> = mutableMapOf()

    fun putTreeDictWrap(code: String, treeDictWrap: TreeDictWrap) {
        sysDictListCache[code] = treeDictWrap
    }

    fun putDictList(code: String, dictList: List<ITreeDict<*>>): TreeDictWrap {
        val treeDictWrap =
            TreeDictWrap()
        treeDictWrap.sysDictList = dictList
        putTreeDictWrap(code, treeDictWrap)
        return treeDictWrap
    }

    fun getSysDictWrap(code: String): TreeDictWrap? {
        return sysDictListCache[code]
    }

    fun dictListIsExist(code: String): Boolean {
        return sysDictListCache.containsKey(code)
    }

    fun putDictBizList(code: String, dictList: List<ITreeDict<*>>): TreeDictWrap {
        val treeDictWrap =
            TreeDictWrap()
        treeDictWrap.sysDictList = dictList
        sysDictListCache[code] = treeDictWrap
        return treeDictWrap
    }

    fun getSysDictBizWrap(code: String): TreeDictWrap? {
        return sysDictListCache[code]
    }

    fun dictBizListIsExist(code: String): Boolean {
        return sysDictBizListCache.containsKey(code)
    }

    override fun clear() {
        super.clear()
        sysDictListCache.clear()
        sysDictBizListCache.clear()
    }
}